/**
 * @Title: TokenController.java
 * @Package com.qding.park.api.web.service.controller
 * @Description: TODO
 * Copyright: Copyright (c) 2011 
 * Company:千丁互联
 * 
 * @author Comsys-Administrator
 * @date 2016年8月16日 下午2:56:00
 * @version V1.0
 */

package com.qding.park.manager.rest.controller;

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.qding.park.common.web.controller.BaseController;
import com.qding.park.manager.cache.ConfigDataCacheInter;
import com.qding.park.manager.common.rest.domain.AnswerMsg;
import com.qding.park.manager.common.rest.domain.AnswerMsgFactoryImpl;
import com.qding.park.manager.common.rest.domain.CreateTokenData;
import com.qding.park.manager.pojo.sms.device.InviteVisitNotice;
import com.qding.park.manager.sms.DevicePushInterfaceService;
import com.qding.park.manager.sms.impl.DevicePushInterfaceServiceImpl;

/**
 * @ClassName: TokenController
 * @Description: token控制器
 * @author Comsys-Administrator
 * @date 2016年8月16日 下午2:56:00
 *
 */
@RestController
@EnableAutoConfiguration
public class TokenController extends WebBaseController {

	@Autowired
	private ConfigDataCacheInter configDataCacheInter;

	@RequestMapping("/createToken")
	public AnswerMsg createToken() {

		configDataCacheInter.queryParkSpace(104);
		CreateTokenData data = new CreateTokenData();
		data.setToken(UUID.randomUUID().toString());

		return AnswerMsgFactoryImpl.createAnswerMsg(data);

	}
	
	@RequestMapping("/test")
	public AnswerMsg test() {
		return AnswerMsgFactoryImpl.createAnswerMsg(null);

	}
	
	
	@RequestMapping("/pushDevice")
	public AnswerMsg pushDevice(String userId) {
		
		DevicePushInterfaceService devicePush = new DevicePushInterfaceServiceImpl();
		InviteVisitNotice notice=new InviteVisitNotice();
		notice.setCarNum("粤B12345");
		notice.setMemberId(userId);
		devicePush.inviteVisitNotice(notice);
		return AnswerMsgFactoryImpl.createAnswerMsg(null);

	}

}
